<template>
  <div class="app" />
</template>

<script>
import { postRoleAPI } from '@/api/role'
export default {
  props: {
    testAddData: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {}
  },
  watch: {
    testAddData(newValue, oldValue) {
      newValue && this.addListData()
    }
  },
  methods: {
    circularScripts(apiFunction, { name, description, state }) {
      for (let i = 0; i < this.num; i++) {
        apiFunction({
          name: name + i,
          description: description + i,
          state: parseInt(state)
        })
      }
    },
    addListData() {
      this.circularScripts(postRoleAPI, {
        name: 'test',
        description: 'test',
        state: '1'
      })
    }
  }
}
</script>

<style>
</style>
